home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Net / Utilities / Seer family 2.0 / docs / unloved files / qqpdl_to_code.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-29  |  3.6 KB  |  138 lines  |  [TEXT/KAHL]

  1. /*
  2.     data structures for pdl (packet descriptor langage
  3.  
  4. */
  5. #ifndef eextern
  6. #define eextern extern
  7. #endif
  8. #include "xsetjmp.h"    /*setjmp.h + protypes*/
  9.  
  10. void pr_error(char *);
  11.  
  12. typedef struct {
  13.     uint32 nd_print:4,    /*how to print*/
  14.             nd_resv1:11,    /*unused, reserved for expansion*/
  15.            nd_indreg:5,    /*indirect (value) register*/
  16.            nd_lodreg:5,    /*load field value into this register*/
  17.            nd_indsize:1, /*size is indirect (nd_size is register)*/
  18.             nd_size:6;    /*item size*/
  19. }nd_fvalue;    /*what the value field of a 'field'*/
  20.  
  21. /*
  22.     nd_print values
  23. */
  24. #define HEX     0x00000000    /*print field in hex*/
  25. #define DEC     0x10000000    /*print field in decimal*/
  26. #define NOPRINT 0x20000000    /*don't print at all*/
  27. #define CNT_STR 0x30000000    /*print a counted ascii string*/
  28. #define IP_ADR  0x40000000  /*an ip address*/
  29.  
  30. /*map the above fake names into real values*/
  31. #define PR_REAL(xxx) ((xxx)>>28)
  32.  
  33. #define VIND(xxx) ((xxx)<<12)    /*load value inderectly*/
  34. #define VLOAD(xxx) ((xxx)<<7)    /*store value into a register*/
  35.  
  36. #define SIND(xxx) (0x40|(xxx))    /*load a size inderectly*/
  37.  
  38. #define PDL_REG_MAX 31 /*the maximum register number*/
  39.  
  40. /*
  41.     define a bit field
  42. */
  43. void pdl_field(uint32,char *);
  44. #define field(fld_name,fld_size,fld_radix) \
  45.   pdl_field(fld_radix|fld_size,fld_name);
  46.  
  47. /*
  48.     name a bit pattern
  49. */
  50. #define name(nam_name,nam_value) \
  51. if(ppg.pr_last_value==(nam_value)) { /*match last field value?*/ \
  52.  /*our value matched the last 'field' value so print our name*/ \
  53.  OUT_str("(");         \
  54.  OUT_str(nam_name);    \
  55.  OUT_str(")"); }
  56.  
  57. /*
  58.     define a sub protocol
  59. */
  60. #define protocol(prot_name,prot_adr,prot_value,reg) \
  61.  if(ppg.pr_last_value==(prot_value)) { /*match last field value?*/ \
  62.      /*our value matched the last 'field' value so print our name*/ \
  63.      OUT_str("("); \
  64.      OUT_str(prot_name); \
  65.      OUT_str(")"); \
  66.     /*remember the address of our protocol handler for later*/ \
  67.      ppg.pr_regs[reg]=(uint32)&prot_adr; \
  68.      }
  69.  
  70. #define loop_till_end(lc_routine) \
  71.  while(ppg.pr_size>0) \
  72.      lc_routine();
  73.  
  74. #define loop_count(loop_reg,lc_routine) \
  75.  {long count; \
  76.   count=ppg.pr_regs[loop_reg];    /*get the repeat count*/ \
  77.   while((--count) >= 0)            /*loop the specified number of times*/ \
  78.        lc_routine();    \
  79.  }
  80.  
  81. #define pdl_begin(xxxx) \
  82.     void xxxx(void); \
  83.     void xxxx(){
  84. /*pdlbegin for routines that are already prototyped (by pdl_extern)*/
  85. #define pdl_begin_forward(xxxx) \
  86.     void xxxx(){
  87.  
  88.  
  89. #define pdl_extern(xxxx) extern void xxxx(void); 
  90.  
  91. #define pdl_end }
  92.  
  93. #define thats_all if(ppg.pr_size>0)pr_error("??excess data");
  94.  
  95. #define pdl_indirect_gosub(reg) \
  96.  {void (*sp_rtn)();        \
  97.  sp_rtn=(void (*)())ppg.pr_regs[reg]; \
  98.  if(sp_rtn!=NIL) (*sp_rtn)(); \
  99.  }
  100.  
  101. #define pdl_gosub(pdl_go) \
  102.     pdl_go();
  103.  
  104. #define pdl_special(pdl_go) \
  105.     pdl_go(&ppg);
  106.  
  107. #define pdl_zero(reg) ppg.pr_regs[reg]=0;
  108.  
  109. void pdl_print(uint8 *,void (*)(),uint16);
  110.  
  111. /*
  112.     interpretor globals for special functions to use
  113. */
  114.  
  115. #define BITS_PER_DATA 8        /*how big a data item is*/
  116. #define DATA_IS uint8        /*change to uint16 if all packets word aligned*/
  117.  
  118. typedef struct {
  119.  uint32 pr_last_value;        /*last field value*/
  120.  uint32 pr_size;            /*bits left to use in data packet*/
  121.  uint8 pr_curb;                /*current bit position for reading data*/
  122.  DATA_IS *pr_data;            /*pointer to data*/
  123.  uint32 pr_regs[PDL_REG_MAX+1]; /*the pdl registers*/
  124.  jmp_buf pr_jmp_buf;        /*error throw for pdl errors*/
  125. } pdl_pr_dat,*pdl_pr_dat_pt;
  126.  
  127. eextern pdl_pr_dat ppg;    /*pdl print globals*/
  128.  
  129. /*
  130.     name pdl registers
  131. */
  132. #define t0 1        /*a temporary*/
  133. #define t1 2
  134. #define ddp_type 3    /*ddp type (loaded for both short and long ddps)*/
  135. #define proto 4        /*holds protocol gosub address*/
  136. #define zipcount 5    /*zone info protocol repeat count*/
  137. #define ip_type 6    /*ip packet type*/
  138.